package ArrayAddSubtract;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
public class ArraySearch {
    public static void main(String[] args) {

        String[] names = {"Tom","Sam","Jack","Alice","Ruby","Robin"};
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入想查找的原英文名：");
        String keyWord = sc.next();

        String[] tempName = new String[0];
        int j= 0;
        for (int i = 0; i < names.length; i++) {
            if (names[i].toLowerCase().contains(keyWord.toLowerCase())){
                tempName    = Arrays.copyOf(tempName,tempName.length+1);
                tempName[j++] = names[i];
            }
        }
        System.out.println("根据你输入的"+keyWord+"关键字查询结果如下：");
        if (tempName.length==0){
            System.out.println("没有要查询的名字");
        }
        else {
            for (String name:tempName) {
                System.out.println(name);
            }
        }


    }
}
